asm
  ld sp,$0FFF
  end asm

goto jmp01:
asm
org $1000
end asm
jmp01:

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"
#include "./library/pacmanldir.bas"

dim eee as uinteger at $0C10
dim seed as uinteger at $0C12
dim ee0 as uinteger at $0C14
dim ee1 as uinteger at $0C16
dim ee2 as uinteger at $0C18
dim ee3 as uinteger at $0C1A
dim eex as uinteger at $0C1C
dim eey as uinteger at $0C1E


sub polyplayputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte)
  poke $F800+txp1+(typ1*64),tch1
  end sub


seed=0


'- why poking at $FFFF crashes?


for ee0=0 to 4
  for ee1=0 to 4
    for ee2=0 to 4
      pacmanldir($EC00+((ee0*25+ee1*5+ee2)*8), @tiles01+(8*ee0),8)
      pacmanldir($F000+((ee0*25+ee1*5+ee2)*8), @tiles01+(8*ee1),8)
      pacmanldir($F400+((ee0*25+ee1*5+ee2)*8), @tiles01+(8*ee2),8)
      next:next:next

for ee0=0 to 31
  for ee1=0 to 63
    seed=smsrnd(seed)
    polyplayputchar(ee1,ee0,128+(seed mod 125) )
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    polyplayputchar(ee1+47,ee0+15,ee0*16+ee1)
    next:next

eex=8:eey=8
eee=0
do

polyplayputchar(1,1,48+(int(eee/100) mod 10))
polyplayputchar(2,1,48+(int(eee/10) mod 10))
polyplayputchar(3,1,48+(eee mod 10))

ee0=in($84) bxor $FF
polyplayputchar(1,3,48+(int(ee0/100) mod 10))
polyplayputchar(2,3,48+(int(ee0/10) mod 10))
polyplayputchar(3,3,48+(ee0 mod 10))


eex=eex+((ee0 band 2)/2)-((ee0 band 4)/4)
eey=eey+((ee0 band 16)/16)-((ee0 band 8)/8)

if eex<0 then:eex=0:end if
if eex>63 then:eex=63:end if
if eey<0 then:eey=0:end if
if eey>31 then:eey=31:end if


polyplayputchar(eex,eey,eee)

eee=eee+1
loop




do:loop

'----------------------------------------------------------------------






do

for eee=$F800 to $FFFE '- videoram - $F800..$FFFF
  seed=smsrnd(seed)
  poke eee,eee
  pacmandelay(500)
  next

'for eee=$EC00 to $F7FF '- character - ram $EC00..$F7FF
'  seed=smsrnd(seed)
'  poke eee,seed
'  pacmandelay(500)
'  next

for eee=$F800 to $FFFE '- videoram - $F800..$FFFF
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(500)
  next

loop




for eee=$EA08 to $EAF3 '- gfx1 - $E800..$EBFF
  seed=smsrnd(seed)
  poke eee,seed
  pacmandelay(500)
  next




do





loop

do




loop




do
loop





'#- static ADDRESS_MAP_START( polyplay_map, AS_PROGRAM, 8, polyplay_state )
'#- AM_RANGE(0x0000, 0x0bff) AM_ROM
'#- AM_RANGE(0x0c00, 0x0fff) AM_RAM
'#- AM_RANGE(0x1000, 0x8fff) AM_ROM
'#- AM_RANGE(0xe800, 0xebff) AM_ROM AM_REGION("gfx1", 0)
'#- AM_RANGE(0xec00, 0xf7ff) AM_RAM_WRITE(polyplay_characterram_w) AM_SHARE("characterram")
'#- AM_RANGE(0xf800, 0xffff) AM_RAM AM_SHARE("videoram")



'--------------------------------------------------

tiles01:

asm

  defb %00000000
  defb %00000000
  defb %00000000
  defb %00000000
  defb %00000000
  defb %00000000
  defb %00000000
  defb %00000000

  defb %10001000
  defb %10001000
  defb %00100010
  defb %00100010
  defb %10001000
  defb %10001000
  defb %00100010
  defb %00100010

  defb %11001100
  defb %10101010
  defb %00110011
  defb %10101010
  defb %11001100
  defb %10101010
  defb %00110011
  defb %10101010

  defb %11101110
  defb %11101110
  defb %10111011
  defb %10111011
  defb %11101110
  defb %11101110
  defb %10111011
  defb %10111011

  defb %11111111
  defb %11111111
  defb %11111111
  defb %11111111
  defb %11111111
  defb %11111111
  defb %11111111
  defb %11111111



end asm









